home *** CD-ROM | disk | FTP | other *** search
/ Assassins - Ultimate CD Games Collection 4 / Assassins 4 (1999)(Weird Science).iso / misc / omega / source / env.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-02  |  8.3 KB  |  344 lines

  1. /* omega copyright (c) 1987,1988,1989 by Laurence Raphael Brothers */
  2. /* env.c */
  3. /* some load_* routines for special environments */
  4.  
  5. #include "glob.h"
  6.  
  7. /* loads the arena level into Level*/
  8. void load_arena()
  9. {
  10.   int i,j;
  11.   char site;
  12.   pob box=((pob)checkmalloc(sizeof(objtype)));
  13.   FILE *fd;
  14.  
  15.   *box = Objects[THINGID+0];
  16.  
  17.   TempLevel = Level;
  18.   if (ok_to_free(TempLevel)) {
  19. #ifndef SAVE_LEVELS
  20.     free_level(TempLevel);
  21. #endif
  22.     TempLevel = NULL;
  23.   }
  24. #ifndef SAVE_LEVELS
  25.   Level = ((plv) checkmalloc(sizeof(levtype)));
  26. #else
  27.   msdos_changelevel(TempLevel,0,-1);
  28.   Level = &TheLevel;
  29. #endif
  30.   clear_level(Level);
  31.   Level->environment = E_ARENA;
  32.   strcpy(Str3,Omegalib);
  33.   strcat(Str3,"arena.dat");
  34.   fd = checkfopen(Str3,"rb");
  35.   site = cryptkey("arena.dat");
  36.   for(j=0;j<LENGTH;j++) {
  37.     for(i=0;i<WIDTH;i++) {
  38.       Level->site[i][j].lstatus = SEEN+LIT;
  39.       Level->site[i][j].roomnumber = RS_ARENA;
  40.       site = getc(fd)^site;
  41.       Level->site[i][j].p_locf = L_NO_OP;
  42.       switch(site) {
  43.       case 'P':
  44.     Level->site[i][j].locchar = PORTCULLIS;
  45.     Level->site[i][j].p_locf = L_PORTCULLIS;
  46.     break;
  47.       case 'X':
  48.     Level->site[i][j].locchar = FLOOR;
  49.     Level->site[i][j].p_locf = L_ARENA_EXIT;
  50.     break;
  51.       case '#':
  52.     Level->site[i][j].locchar = WALL;
  53.     break;
  54.       case '.':
  55.     Level->site[i][j].locchar = FLOOR;
  56.     break;
  57.       }
  58.       Level->site[i][j].showchar = Level->site[i][j].locchar;
  59.     }
  60.     site = getc(fd)^site;
  61.   }
  62.   fclose(fd);
  63. #ifdef AMIGA
  64.   int fix1 = 60;
  65.   int fix2 = 7;
  66.   Level->site[fix1][fix2].creature = Arena_Monster;
  67. #else
  68.   Level->site[60][7].creature = Arena_Monster;
  69. #endif
  70.   Arena_Monster->x = 60;
  71.   Arena_Monster->y = 7;
  72.   Arena_Monster->sense = 50;
  73.   m_pickup(Arena_Monster,box);
  74.   m_status_set(Arena_Monster,AWAKE);
  75.   Level->mlist = (pml) checkmalloc(sizeof(mltype));
  76.   Level->mlist->m = Arena_Monster;
  77.   Level->mlist->next = NULL;
  78.   /* hehehehe cackled the dungeon master.... */
  79.   print2("Your opponent holds the only way you can leave!");
  80.   Arena_Monster->hp += Arena_Monster->level*10;
  81.   Arena_Monster->hit += Arena_Monster->hit;
  82.   Arena_Monster->dmg += Arena_Monster->dmg/2;
  83. }
  84.  
  85. /* loads the sorcereror's circle into Level*/
  86. void load_circle(populate)
  87. int populate;
  88. {
  89.   int i,j;
  90.   int safe = (Player.rank[CIRCLE] > 0);
  91.   char site;
  92.   FILE *fd;
  93.  
  94.   TempLevel = Level;
  95.   if (ok_to_free(TempLevel)) {
  96. #ifndef SAVE_LEVELS
  97.     free_level(TempLevel);
  98. #endif
  99.     TempLevel = NULL;
  100.   }
  101. #ifndef SAVE_LEVELS
  102.   Level = ((plv) checkmalloc(sizeof(levtype)));
  103. #else
  104.   msdos_changelevel(TempLevel,0,-1);
  105.   Level = &TheLevel;
  106. #endif
  107.   clear_level(Level);
  108.   Level->environment = E_CIRCLE;
  109.   strcpy(Str3,Omegalib);
  110.   strcat(Str3,"circle.dat");
  111.   fd = checkfopen(Str3,"rb");
  112.   site = cryptkey("circle.dat");
  113.   for(j=0;j<LENGTH;j++) {
  114.     for(i=0;i<WIDTH;i++) {
  115.       Level->site[i][j].lstatus = 0;
  116.       Level->site[i][j].roomnumber = RS_CIRCLE;
  117.       Level->site[i][j].p_locf = L_NO_OP;
  118.       site = getc(fd)^site;
  119.       switch(site) {
  120.       case 'P':
  121.     Level->site[i][j].locchar = FLOOR;
  122.     if (populate) {
  123.       make_prime(i,j); /* prime sorceror */
  124.       Level->site[i][j].creature->specialf = M_SP_PRIME;
  125.       if (! safe) m_status_set(Level->site[i][j].creature,HOSTILE);
  126.     }
  127.     break;
  128.       case 'D':
  129.     Level->site[i][j].locchar = FLOOR;
  130.     if (populate) {
  131.       make_site_monster(i,j,ML9+7); /* prime circle demon */
  132.       if (safe) m_status_reset(Level->site[i][j].creature,HOSTILE);
  133.       Level->site[i][j].creature->specialf = M_SP_COURT;
  134.     }
  135.     break;
  136.       case 's':
  137.     Level->site[i][j].locchar = FLOOR;
  138.     if (populate) {
  139.       make_site_monster(i,j,ML4+13); /* servant of chaos */
  140.       Level->site[i][j].creature->specialf = M_SP_COURT;
  141.       if (safe) m_status_reset(Level->site[i][j].creature,HOSTILE);
  142.     }
  143.     break;
  144.       case 'e':
  145.     Level->site[i][j].locchar = FLOOR;
  146.     if (populate) {
  147.       make_site_monster(i,j,ML2+7); /* enchanter */
  148.       Level->site[i][j].creature->specialf = M_SP_COURT;
  149.       if (safe) m_status_reset(Level->site[i][j].creature,HOSTILE);
  150.     }
  151.     break;
  152.       case 'n':
  153.     Level->site[i][j].locchar = FLOOR;
  154.     if (populate) {
  155.       make_site_monster(i,j,ML5+6); /* necromancer */
  156.       Level->site[i][j].creature->specialf = M_SP_COURT;
  157.       if (safe) m_status_reset(Level->site[i][j].creature,HOSTILE);
  158.     }
  159.     break;
  160.       case 'T':
  161.     Level->site[i][j].locchar = FLOOR;
  162.     if (populate) {
  163.       make_site_monster(i,j,ML9+4); /* High Thaumaturgist */
  164.       Level->site[i][j].creature->specialf = M_SP_COURT;
  165.       if (safe) m_status_reset(Level->site[i][j].creature,HOSTILE);
  166.     }
  167.     break;
  168.       case '#':
  169.     Level->site[i][j].locchar = WALL;
  170.     Level->site[i][j].aux = 1000; 
  171.     break;
  172.       case 'L':
  173.     Level->site[i][j].locchar = FLOOR;
  174.     Level->site[i][j].p_locf = L_CIRCLE_LIBRARY;
  175.     break;
  176.       case '?':
  177.     Level->site[i][j].locchar = FLOOR;
  178.     Level->site[i][j].p_locf = L_TOME1;
  179.     break;
  180.       case '!':
  181.     Level->site[i][j].locchar = FLOOR;
  182.     Level->site[i][j].p_locf = L_TOME2;
  183.     break;
  184.       case 'S':
  185.     Level->site[i][j].locchar = FLOOR;
  186.     lset(i,j,SECRET);
  187.     break;
  188.       case '.':
  189.     Level->site[i][j].locchar = FLOOR;
  190.     break;
  191.       case '-':
  192.     Level->site[i][j].locchar = CLOSED_DOOR;
  193.     break;
  194.       }
  195.     }
  196.     site = getc(fd)^site;
  197.   }
  198.   fclose(fd);
  199. }
  200.  
  201. /* make the prime sorceror */
  202. void make_prime(i,j)
  203. int i,j;
  204. {
  205.   pml ml = ((pml) checkmalloc(sizeof(mltype)));
  206.   pmt m = ((pmt) checkmalloc(sizeof(montype)));
  207.   pol ol;
  208.   pob o;
  209.   make_hiscore_npc(m,10); /* 10 is index for prime */
  210.   m->x = i;
  211.   m->y = j;
  212.   Level->site[i][j].creature = m;
  213.   ml->m = m;
  214.   ml->next = Level->mlist;
  215.   Level->mlist = ml;
  216.   
  217.   if (Objects[ARTIFACTID+21].uniqueness != UNIQUE_TAKEN) {
  218.     ol  = ((pol) checkmalloc(sizeof(oltype)));
  219.     o  = ((pob) checkmalloc(sizeof(objtype)));
  220.     *o = Objects[ARTIFACTID+21];
  221.     ol->thing = o;
  222.     ol->next = NULL;
  223.     m->possessions = ol;
  224.   }
  225. }
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232. /* loads the court of the archmage into Level*/
  233. void load_court(populate)
  234. int populate;
  235. {
  236.   int i,j;
  237.   char site;
  238.   FILE *fd;
  239.  
  240.   TempLevel = Level;
  241.   if (ok_to_free(TempLevel)) {
  242. #ifndef SAVE_LEVELS
  243.     free_level(TempLevel);
  244. #endif
  245.     TempLevel = NULL;
  246.   }
  247. #ifndef SAVE_LEVELS
  248.   Level = ((plv) checkmalloc(sizeof(levtype)));
  249. #else
  250.   msdos_changelevel(TempLevel,0,-1);
  251.   Level = &TheLevel;
  252. #endif
  253.   clear_level(Level);
  254.   Level->environment = E_COURT;
  255.   strcpy(Str3,Omegalib);
  256.   strcat(Str3,"court.dat");
  257.   fd = checkfopen(Str3,"rb");
  258.   site = cryptkey("court.dat");
  259.   for(j=0;j<LENGTH;j++) {
  260.     for(i=0;i<WIDTH;i++) {
  261.       Level->site[i][j].lstatus = 0;
  262.       Level->site[i][j].roomnumber = RS_COURT;
  263.       Level->site[i][j].p_locf = L_NO_OP;
  264.       site = getc(fd)^site;
  265.       switch(site) {
  266.       case '5':
  267.     Level->site[i][j].locchar = CHAIR;
  268.     Level->site[i][j].p_locf = L_THRONE;
  269.     if (populate) {
  270.       make_specific_treasure(i,j,ARTIFACTID+22);
  271.       make_archmage(i,j);
  272.       m_status_reset(Level->site[i][j].creature,HOSTILE);
  273.       m_status_reset(Level->site[i][j].creature,MOBILE);
  274.     }
  275.     break;
  276.       case 'e':
  277.     Level->site[i][j].locchar = FLOOR;
  278.     if (populate) {
  279.       make_site_monster(i,j,ML2+7); /* enchanter */
  280.       m_status_reset(Level->site[i][j].creature,HOSTILE);
  281.       Level->site[i][j].creature->specialf = M_SP_COURT;
  282.     }
  283.     break;
  284.       case 'n':
  285.     Level->site[i][j].locchar = FLOOR;
  286.     if (populate) {
  287.       make_site_monster(i,j,ML5+6); /* necromancer */
  288.       m_status_reset(Level->site[i][j].creature,HOSTILE);
  289.       Level->site[i][j].creature->specialf = M_SP_COURT;
  290.     }
  291.     break;
  292.       case 'T':
  293.     Level->site[i][j].locchar = FLOOR;
  294.     if (populate) {
  295.       make_site_monster(i,j,ML9+4); /* High Thaumaturgist */
  296.       m_status_reset(Level->site[i][j].creature,HOSTILE);
  297.       Level->site[i][j].creature->specialf = M_SP_COURT;
  298.     }
  299.     break;
  300.       case '#':
  301.     Level->site[i][j].locchar = WALL;
  302.     Level->site[i][j].aux = 1000; 
  303.     break;
  304.       case 'G':
  305.     Level->site[i][j].locchar = FLOOR;
  306.     Level->site[i][j].locchar = FLOOR;
  307.     if (populate) {
  308.       make_site_monster(i,j,ML0+3); /* guard */
  309.       m_status_reset(Level->site[i][j].creature,HOSTILE);
  310.     }
  311.     break;
  312.       case '<':
  313.     Level->site[i][j].locchar = STAIRS_UP;
  314.     Level->site[i][j].p_locf = L_ESCALATOR;
  315.     break;
  316.       case '.':
  317.     Level->site[i][j].locchar = FLOOR;
  318.     break;
  319.       }
  320.     }
  321.     site = getc(fd)^site;
  322.   }
  323.   fclose(fd);
  324. }
  325.  
  326.  
  327.  
  328. /* make the archmage */
  329. void make_archmage(i,j)
  330. int i,j;
  331. {
  332.   pml ml = ((pml) checkmalloc(sizeof(mltype)));
  333.   pmt m = ((pmt) checkmalloc(sizeof(montype)));
  334.   make_hiscore_npc(m,9); /* 9 is index for archmage */
  335.   m->x = i;
  336.   m->y = j;
  337.   Level->site[i][j].creature = m;
  338.   ml->m = m;
  339.   ml->next = Level->mlist;
  340.   Level->mlist = ml;
  341.   m->specialf = M_SP_COURT;
  342. }
  343.  
  344.